package com.service.business.order.utils;

import com.service.business.base.controller.rep.ConfigRep;
import com.service.business.base.service.ConfigService;
import com.service.business.utils.DateUtil;
import com.service.dao.constants.ConfigConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年12月05日</dd>
 * </dl>
 *
 * @author
 */
@Component
public class OrderUtils {

    @Autowired
    private ConfigService configService;

    public Long getOvertime(Date orderTime) {
        ConfigRep config = configService.getConfigRepByName(ConfigConstants.ORDER_OVERDUE_TIME);
        return DateUtil.getValidTime(orderTime, Integer.parseInt(config.getConfValue()));
    }

    public boolean isOvertime(Date orderTime) {
        return getOvertime(orderTime) <= 0;
    }

}
